package com.tzq.SERVLET;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tzq.CLASS.MD5;
import com.tzq.JAVABEAN.ConnectDB;

/**
 * Servlet implementation class ResetPassword
 */
public class ResetPassword extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ResetPassword() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String userid=request.getParameter("userid");
		String pwd = request.getParameter("NewPwd");
		MD5 md5 = new MD5();
		pwd = md5.getMD5ofStr(pwd);
		String sql = "update Userinfo set Pwd=? where UserID=?";
		String[] SqlParam = {pwd,userid};
		int[] WhichInt = {0,1};
		ConnectDB conn = new ConnectDB();
		boolean flag= conn.updatesql(sql, SqlParam, 2, WhichInt);
		conn.closeConnection();
		try {
			response.sendRedirect("Skip.jsp?p=Modify&flag="+flag);
		} catch (Exception e){
			e.printStackTrace();
		}
	}

}
